/*
 * LowSpdClk.c
 *
 *  Created on: 24-01-2012
 *      Author: mhl
 */

#include "LowSpdClk.h"

inline void LSClk_Prescaler(Uint16 prescale)			//  LowSpeed to 10 razy mniej niz SYSCLK
{

	SysCtrlRegs.LOSPCP.bit.LSPCLK	= prescale & 0x07;	// 3 ostatnie bity decyduja
}

inline void LSClk_SPI(Uint16 enable)
{
	SysCtrlRegs.PCLKCR0.bit.SPIAENCLK= enable;
}
inline void LSClk_ePWM1(Uint16 enable)
{
	SysCtrlRegs.PCLKCR1.bit.EPWM1ENCLK = enable;
}
inline void LSClk_ePWM2(Uint16 enable)
{
	SysCtrlRegs.PCLKCR1.bit.EPWM2ENCLK = enable;
}

void LSClk_Config(Uint16 prescaler, Uint16 epwm1, Uint16 epwm2, Uint16 spia )
{
	EALLOW;
	LSClk_Prescaler(prescaler);
	LSClk_ePWM1(0x01);
	LSClk_ePWM2(0x01);
	LSClk_SPI(0x01);
	EDIS;
}
